package com.amtf.datafile2.cfg.txt;

import com.amtf.datafile2.DataField;
import com.amtf.datafile2.cfg.std.StdDataFieldDefinition;
import com.amtf.datafile2.core.txt.TxtDataField;

public class TxtDataFieldDefinition extends StdDataFieldDefinition<TxtDataTableDefinition> {

	private char quote = '"';
	private boolean forceQuote = false;

	public TxtDataFieldDefinition(String name) {
		super(name);
	}

	public TxtDataFieldDefinition(String name, TxtDataTableDefinition dataTableDefinition) {
		super(name, dataTableDefinition);
		this.quote = dataTableDefinition.getSmartQuote();
	}

	@Override
	public TxtDataFieldDefinition clone() {
		TxtDataFieldDefinition newObj = new TxtDataFieldDefinition(name);
		copyTo(newObj);
		newObj.quote = this.quote;
		newObj.forceQuote = this.forceQuote;
		return newObj;
	}

	public DataField newDataFieldInstance() {
		return new TxtDataField(this);
	}

	@Override
	public boolean equals(Object obj) {
		TxtDataFieldDefinition f1 = (TxtDataFieldDefinition) obj;

		return super.equals(obj) && f1.quote == this.quote;
	}

	public char getQuote() {
		return quote;
	}

	public void setQuote(char quote) {
		this.quote = quote;
	}

	public boolean isForceQuote() {
		return forceQuote;
	}

	public void setForceQuote(boolean forceQuote) {
		this.forceQuote = forceQuote;
	}

	// public void validate(DataField value) {
	// }

}
